﻿Public Class clsChiTietSach
    Public Shared Function ThemS(ByVal IDSach As String, ByVal MaSach As String, ByVal TinhTrang As String, ByVal TrangThai As String) As Boolean
        Return db.Query("Insert into Sub_Sach (IDSach,MaSach,TinhTrang,TrangThai) values('" & IDSach & "','" & MaSach & "',N'" & TinhTrang & "',N'" & TrangThai & "')")
    End Function
    'Public Shared Function DanhSachS() As DataTable
    '    Return db.QueryTable("Select TenSach,IDSach,TinhTrang,TrangThai from Sach s inner join Sub_Sach ss on s.MaSach=ss.MaSach")
    'End Function
    Public Shared Function SuaS(ByVal IDSach As String, ByVal MaSach As String, ByVal TinhTrang As String, ByVal TrangThai As String)
        Return db.Query("Update Sub_Sach set MaSach='" & MaSach & "',TinhTrang=N'" & TinhTrang & "',TrangThai='" & TrangThai & "' where IDSach='" & IDSach & "'")
    End Function
    Public Shared Function XoaS(ByVal IDSach As String) As Boolean
        Return db.Query("Delete Sub_Sach where IDSach='" & IDSach & "'")
    End Function
    Public Shared Function SachCuaDauSach(ByVal masach As String) As DataTable
        Return db.QueryTable("Select TenSach,IDSach,TinhTrang,TrangThai from Sach s inner join Sub_Sach ss on s.MaSach=ss.MaSach where ss.MaSach='" & masach & "'")

    End Function

    Public Shared Function ThongTinSach(ByVal IDsach As String) As DataTable
        Return db.QueryTable("select IDSach,TenSach,TrangThai,TinhTrang from Sub_Sach ss inner join Sach s on s.MaSach=ss.MaSach where IDSach = '" & IDsach & "'")
    End Function
End Class
